// JavaScript Document
$(function(){
		function hellotime()
		{
			var date=new Date();
			var dt="你好，现在时间为："+(date.getFullYear())+"年 "+(date.getMonth()+1)+"月 "+(date.getDate()<10?("0"+date.getDate()):date.getDate())+"日 ";
			dt+=(date.getHours()<10?("0"+date.getHours()):date.getHours())+":";
			dt+=(date.getMinutes()<10?("0"+date.getMinutes()):date.getMinutes())+":";
			dt+=(date.getSeconds()<10?("0"+date.getSeconds()):date.getSeconds())+"";
			$("#showtime").text(dt);
			window.setTimeout(function(){
				hellotime();
				},1000);
			
		}
		function mover(div,uclass)
		{
				$(div).siblings(".liselected").children("a").css("color","#000");
				
			$(div).siblings(".liselected").removeClass("liselected").addClass("liunselected");
		
			$(div).removeClass("liunselected").addClass("liselected");
			$(div).children("a").css("color","#f00");
			
			
			$("."+uclass).hide();
			var s="div."+uclass+"[index="+$(div).attr("index")+"]";
			$(s).show();
			
		}
		function initpicture()
		{
			var count=$("#tpcontain img").size();
			
			for(var i=count;i>=1;i--)
			{
				var sp="<span class=\"tipspan\" index=\""+i+"\">"+(i)+"</span>";
				$("#tpbottom").prepend($(sp));
			}
		}
		function randomHide(image,count)
		{
			var down=parseInt(Math.random()*count+1);
			
			switch(down)
			{
					case 1:{
						image.show();
						break;
					}
					case 2:{
						image.slideDown("slow");
						break;
					}
					case 3:{
						image.fadeIn("slow");
					}
					default:
					image.show();
			}
			
			
		}
		function animate()
		{
			
					
						var sp=$("#tpbottom span.tipspanselected:first");
					
						var count=$("#tpbottom span").size();
						var ind=parseInt(sp.text());
							
						var nind=ind%count+1;
						
					
						/*show next*/
						$("#tpcontain img").hide();
						var title=$("#tpcontain  img[index="+nind+"]").attr("tip");
					
						randomHide($("#tpcontain  img[index="+nind+"]"),$("#tpcontain img").size());
						$("#tpbottom "+"span[index="+nind+"]").addClass("tipspanselected")
						.siblings(".tipspanselected").removeClass("tipspanselected").siblings("div").html(title);
						
						window.setTimeout(function(){
							animate();
							},3000);

		}
		function scroll_pic()
		{
			var aimg=$(".div_scroll").children("a:first");
			var count=$(".div_scroll").size()-1;
			var index=parseInt(aimg.attr("index"));
			var nowindex=(index+10)%count;
			aimg.appendTo(".div_scroll");
			$(".div_scroll a[index="+nowindex+"]").fadeIn("slow");
			window.setTimeout(function(){
			scroll_pic();
			},2000);
			
		}
		window.setTimeout(function(){
			scroll_pic();
			},2000);
		hellotime();
		initpicture();
		$("#news ul li.liunselected:not(.null)").mouseover(function(event){
			if(event.target==this)
			{
			mover(event.target,'newscontain');
			event.stopPropagation();
			return false;
			}
			
		});
		
		$(".llleft ul li.liunselected:not(.null)").mouseover(function(event){
			if(event.target==this)
			{
			mover(event.target,"qiyecontain");
			event.stopPropagation();
			return false;
			}
		});
		
		$(".lllright ul li.liunselected:not(.null)").mouseover(function(event){
			if(event.target==this)
				{
			mover(event.target,"renwucontain");
			event.stopPropagation();
			return false;
				}
		});
		
		$("li.liunselected:eq(0)").mouseover();		
		$(".llleft li.liunselected:eq(0)").mouseover();		
		$(".lllright li.liunselected:eq(0)").mouseover();	
		
		/*图片选择*/
		$("#tpcontain img:gt(0)").hide();
		
		$("#tpbottom span").click(function(){
				$("#tpcontain img:visible").hide();
				var index=$(this).attr("index");
				var title=$("#tpcontain  img[index="+index+"]").show().attr("tip");
				$(this).addClass("tipspanselected").siblings("span").removeClass("tipspanselected")
				.siblings("div").html(title);
			});
		$("#tpbottom span:first").click();
		
		window.setTimeout(function(){
			animate();
			},3000);
		
		$("#qa").click(function(){
			if($("#question").val().length==0) 
			{
					alert("问题不能为空");
				return false;
			}
			else
			{
					$("#fform").submit();
			}
			});
		$(".platul li[index]").hover(function(){
			$(this).addClass("platli").siblings(".platli").removeClass("platli");
			var index="div.platcontain[index="+$(this).attr("index")+"]";
			var sp="span[index="+$(this).attr("index")+"]";
			$(this).siblings("span").hide();$(sp).show();
			$("div.platcontain").hide();
			$(index).show();
		},function(){
			
		});
		$("#submit_img").click(function(){
			if($("#qinput").val().length<=0||$("#qinput").val()=="请输入问题") alert("对不起，请输入问题！");
			else $("#fform").submit();
			return false;
		});
		$("#qinput").focus(function(){
			$(this).css("color","#000").val("");
			
		}).blur(function(e) {
            if($(this).val().length<=0)
			$(this).css("color","#ccc").val("请输入问题")
        });;
		$("#login").click(function(e) {
          //  window.open("userinfo/login.jsp");
		
        });
		$("#exit").click(function(e) {
            //window.open("userexit.action");
			window.location="userexit.action";
        });
		
	});